The basic numeric types char
, int
, short
, long
, float
, double
, and
long double
should not be used. Instead, specific-length typedefs should be. This rule helps to clarify the size of the storage, but does
not guarantee portability because of the asymmetric behavior of integral promotion.
Note that it is still important to understand the integer size of the implementation, and developers should be aware of the actual implementation
of the typedefs under these definitions.
Noncompliant code example
int function(unsigned short a) // Noncompliant
{
// ...
}
Compliant solution
#include <stdint.h>
int32_t function(uint16_t a) // Compliant
{
// ...
}